/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.sms.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.sys.entity.Store;
import com.google.common.collect.Lists;

/**
 * 店面诊断结果Entity
 * @author liujiang
 * @version 2013-08-01
 */
@Entity
@Table(name = "store_diagnose")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreDiagnose extends BaseEntity {
	public static final int PER_MOUTHS = 3;
			
	private static final long serialVersionUID = 1L;
	private Long id; 		//店面诊断编号
	private Store store; 		// 店面编号
	private Date diagnose_date; 	// 诊断日期
	private Float total_score; // 总分
	private Float t_performance;	//理论业绩

	private List<StoreDiagnoseDetail> detailList = Lists.newArrayList();
	
	public StoreDiagnose() {
	}

	public StoreDiagnose(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	public Date getDiagnose_date() {
		return diagnose_date;
	}

	public void setDiagnose_date(Date diagnose_date) {
		this.diagnose_date = diagnose_date;
	}

	public Float getTotal_score() {
		return total_score;
	}

	public void setTotal_score(Float total_score) {
		this.total_score = total_score;
	}

	public Float getT_performance() {
		return t_performance;
	}

	public void setT_performance(Float t_performance) {
		this.t_performance = t_performance;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="storeDiagnose")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<StoreDiagnoseDetail> getDetailList() {
		return detailList;
	}

	public void setDetailList(List<StoreDiagnoseDetail> detailList) {
		this.detailList = detailList;
	}
}